<template>
	<view>
		<view class="flex-col page">
			
			<view class="flex-col section">
				<view class="flex-col justify-start">
					<view class="image-wrapper"  :style="{height:(sysInfo.statusBarHeight+sysInfo.safeAreaInsets.top)+'rpx'}"></view>
				</view>
				<view :style="{height:(sysInfo.statusBarHeight+sysInfo.safeAreaInsets.top)+'rpx'}"></view>
				<view class="flex-row justify-between items-center group_2">
					
					<view class="flex-row items-center">
						<view class="flex-col justify-start items-center image-wrapper_2"  v-if="isLogin==false">
							<image class="image_4" src="@/static/wei.png"  style="border-radius: 50%;" />
						</view>
						<view class="flex-col justify-start items-center image-wrapper_2" v-else>
							<image class="image_4" :src="userInfo.photo" @click="goInfo()"  style="border-radius: 50%;" />
						</view>
						<view class="flex-col ml-9" v-if="isLogin==false">
							<text class="self-start text">未登陆</text>
							<view class="flex-col justify-start self-stretch text-wrapper mt-16">
								<view v-if="showWinXin==true">
									<u-button style="display: flex;align-items:left;margin-right: 100rpx;"
										shape="circle" hover-class="none" :custom-style="btn3"
										@click="goLogin">去登录</u-button>
								</view>
								<view v-else>
									<u-button open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber"
										style="display: flex;align-items:left;margin-right: 100rpx;" shape="circle"
										hover-class="none" :custom-style="btn3">去登录</u-button>
								</view>
							</view>
						</view>
						<view class="flex-col ml-9" v-else>
							<text class="self-start text" @click="goInfo()">{{userInfo.nickName}}</text>
							<view class="img_box"  style="display: flex;align-items: center;margin-top: 30rpx;">
								<image v-if="putong && !tuijain&& !xiaoqu&& !quxian" src="/static/putong.png"
									mode="aspectFill"></image>
								<image v-if="tuijain" src="/static/tuiguan.png" mode="aspectFill"></image>
								<image v-if="xiaoqu" src="/static/xiaoqu.png" mode="aspectFill"></image>
								<image v-if="quxian" src="/static/quxian.png" mode="aspectFill"></image>
							</view>
						</view>
					</view>
					<view class="flex-row group_3">
						<image class="image_5"
							src="@/static/img/lindang.png" @click="xitongxinxi()"/>
						<image class="image_6 ml-13"
							src="@/static/img/shezi.png" @tap="goSetting()"/>
					</view>
				</view>
				<view class="flex-row equal-division">
					<view class="flex-row justify-center items-center section_4 equal-division-item">
						<image class="image_7"
							src="@/static/img/libao.png" />
						<view class="flex-col items-start group_4 ml-10-5">
							<text class="font text_3">{{total}}</text>
							<text class="font_2 mt-6-5">账户绑定积分</text>
						</view>
					</view>
					<view class="flex-row justify-center items-center section_4 equal-division-item ml-14-5">
						<image class="image_7"
							src="@/static/img/qian.png" />
						<view class="flex-col items-start group_4 ml-10-5">
							<text class="font text_3">{{available}}</text>
							<text class="font_2 mt-6-5">账户绑定积分</text>
						</view>
					</view>
				</view>
			</view>
			<view class="flex-col list mt-17">
				<view class="flex-row justify-between items-center list-item_1" @click="goYiJian()">
					<view class="flex-row items-center">
						<image class="shrink-0 image_8"
							src="@/static/img/yijian.png" />
						<text class="font_3 ml-15-5">意见反馈</text>
					</view>
					<image class="image_9"
						src="@/static/img/left.png" />
				</view>
				<view class="flex-row justify-between items-center list-item" @click="goService()">
					<view class="flex-row items-center">
						<image class="shrink-0 image_10"
							src="@/static/img/erji.png" />
						<text class="font_3 ml-15">联系客服</text>
					</view>
					<image class="image_9"
						src="@/static/img/left.png" />
				</view>
				<view class="flex-row justify-between items-center list-item" @click="goCoupon()">
					<view class="flex-row items-center">
						<image class="shrink-0 image_11"
							src="@/static/img/bao.png" />
						<text class="font_3 ml-15-5">我的钱包</text>
					</view>
					<image class="image_9"
						src="@/static/img/left.png" />
				</view>
				<view class="flex-row justify-between items-center list-item" @click="goOrder()">
					<view class="flex-row items-center">
						<image class="shrink-0 image_12"
							src="@/static/img/order.png" />
						<text class="font_3 ml-16-5">订单列表</text>
					</view>
					<image class="image_9 image_13"
						src="@/static/img/left.png" />
				</view>
				<view class="flex-row justify-between items-center list-item" @click="goTuijian()">
					<view class="flex-row items-center">
						<image class="shrink-0 image_14"
							src="@/static/img/ren.png" />
						<text class="font_3 ml-15-5">推荐官</text>
					</view>
					<image class="image_9"
						src="@/static/img/left.png" />
				</view>
				<view class="flex-row justify-between items-center list-item" @click="goShegong()">
					<view class="flex-row items-center">
						<image class="shrink-0 image_10"
							src="@/static/img/fenxian.png" />
						<text class="font_3 ml-16-5">自愿者活动</text>
					</view>
					<image class="image_9"
						src="@/static/img/left.png" />
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showWinXin: false,
				jsCode: '',
				showNav: false,
				isLogin: false,
				available: 0,
				total: 0,
				title: 'Hello',
				head: 'https://cdn.uviewui.com/uview/swiper/3.jpg',
				btn1: {
					backgroundColor: "#54C4D0",
					height: '60rpx',
					width: '150rpx'
				},
				btn2: {
					backgroundColor: "#000000",
					color: "white",
					fontSize: "20rpx",
					height: '38rpx',
					width: '110rpx'
				},
				btn3: {
					backgroundColor: "red",
					color: "white",
					fontSize: "20rpx",
					height: '38rpx',
					width: '110rpx'
				},

				userInfo: {
					level: "普通会员",
					nickName: "未登录",
					photo: "../static/weiDL.png",
					red: "0",
					balance: "0",
					mobile: 15822334456,
					activity_photo: '',
					activety_url: "",
					isRead: 0
				},

				putong: true,
				tuijain: false,
				xiaoqu: false,
				quxian: false,
				cont: 0
			}
		},
		onLoad(e) {
			let cont = e.cont

		},
		onShow() {
			// #ifndef MP-WEIXIN
			this.showNav = true;
			this.showWinXin = true;
			// #endif
			this.chooseName();

			if (uni.getStorageSync('token')) {
				this.jifen()
			}

		},
		computed: {
			sysInfo() {
				return this.$store.state.sysInfo;
			}

		},
		methods: {

			async jifen() {
				let res = await this.$request('mall/points/available')
				let res1 = await this.$request('mall/points/total')
				this.available = res.data
				this.total = res1.data
			},
			goShegong() {
				uni.navigateTo({
					url: '/pages/ziyuan/ziyuan'
				})
			},
			goOrder() {
				uni.navigateTo({
					url: '/pages/orderIndex/orderIndex'
				})
			},
			goTuijian() {
				uni.navigateTo({
					url: '/pages/tuijian/tuijian'
				})
			},
			// 获取手机号
			decryptPhoneNumber(e) {
				//console.log(e);
				this.bindPhoneRequest(e);
			},
			bindPhoneRequest(e) {
				uni.login({
					provider: 'weixin',
					success: res => {
						//console.log("deng========>",res);
						if (res.errMsg == "login:ok") {
							this.jsCode = res.code;
							//console.log("code==>",this.jsCode);
						} else {
							uni.showModal({
								title: '登录失败',
								content: '系统异常，请联系管理员'
							});
						}
					}
				})
				setTimeout(() => {
					if (e.detail.errMsg == "getPhoneNumber:ok") {
						//console.log(JSON.stringify(e));
						//console.log(this.jsCode);
						let phone = ''
						if (uni.getStorageSync("phone")) {
							phone = uni.getStorageSync("phone")
						}
						console.log(phone, 'phonephonephoneLosin')
						this.$request("kehu/user/bindWxmallPhone", {
							data: e.detail.encryptedData,
							iv: e.detail.iv,
							jsCode: this.jsCode,
							phone: phone
						}).then(res1 => {
							//console.log("获取手机号======>"+JSON.stringify(res1)+"111");
							this.$store.commit('setToken', res1.msg);
							uni.reLaunch({
								url: './tab1'
							})
						})
					}
				}, 500)
			},
			goLogin() {
				//#ifdef MP-WEIXIN

				//#endif

				//#ifdef H5
				uni.navigateTo({
					url: '../pagesB/login/login'
				})
				//#endif


				//#ifdef APP-PLUS
				const jv = uni.requireNativePlugin('JG-JVerification');
				jv.addCustomViewsClickCallback(id => {
					// // //console.log("自定义点击"+id)

					jv.dismissLoginAuth(true, res => {
						uni.navigateTo({
							url: '../pagesB/login/login'
						})
					})
				});
				// jv.setDialogTheme(410, 390, 0, 0, false)
				jv.setCustomUIWithConfigAndroid({
							// 设置状态栏与导航栏同色
							setStatusBarColorWithNav: true,
							setNumberColor: 0xff2c2c2c,
							setNumberTextBold: true,
							setNavColor: 0xff #4578F7,
					setLogBtnText:"手机号码一键登录",
					setPrivacyState:true,
					// 选择框隐藏
					setPrivacyCheckboxHidden: true,
					// 隐私条款文字居中
					setPrivacyTextCenterGravity: true,
					setPrivacyNameAndUrlBeanList:[{
	  					name:"隐私政策",
	  					url:"http://47.108.56.194:8884/api/xieyi/yulan/2",
	  					beforeName:",",
	  					afterName:","
	  				},{
						name:"用户协议",
						url:"http://47.108.56.194:8884/api/xieyi/yulan/1",
						// beforeName:","
						// afterName:","
					}],
					setAppPrivacyColor:[0xff4169E1,0xffFF6347],
					setPrivacyTextSize:12,
					setPrivacyCheckboxSize:14,
					enableHintToast:true,
					enableHintToastText:"自定义提示linux",
					setLoadingViewEnable:false,
					setStatusBarTransparent:false,
					addCustomViews:[{
						type:"text",
						finishFlag:false,
						id:"id1",
						width:200,
						height:50,
						text:"使用手机验证码登录",
						textSize:14,
						align:15,
						margins:[120,0,0,0],
					}]
				});
				jv.loginAuth({
				        autoFinish:true,
				        timeout:5000
				    },result= > {
								// 结果监听
								let code = JSON.parse(JSON.stringify(result)).code;
								let content = JSON.parse(JSON.stringify(result)).content;
								//console.log(content,code);
								if (code == 6000) {
									let self = this;
									self.$request("kehu/user/loginByJiGuang", {
										content: content
									}).then(res => {
										//console.log("111111111111111111111");
										self.$store.commit('setToken', res.msg);
										if (res.code == 0) {
											uni.reLaunch({
												url: './tab1'
											})
										} else {
											return;
										}
									})
								} else if (code == 6001) {
									uni.showModal({
										title: '提示',
										content: '数据网络未开启'
									})
								} else if (code == 2016) {
									uni.showModal({
										title: '提示',
										content: '当前网络环境不支持认证'
									})
								}
							},
							event => {
								// // //console.log(JSON.stringify(event))
							})
						//#endif
					},
					goActivety() {
						if (this.userInfo.activety_url.trim() == "" || this.userInfo.activety_url == null)
							return
						uni.navigateTo({
							url: "../pagesB/my/activity?url=" + this.userInfo.activety_url
						})
					},
					chooseName() {

						const isLogin = this.$store.state.isLogin;
						console.log(isLogin, "isLoginisLoginisLoginisLoginisLogin");

						this.isLogin = isLogin;
						if (isLogin == true) {
							this.$request("kehu/user/info").then(res => {
								//console.log("res=========>",res);
								//console.log("photo========>",res.data.params.huoDongUrl.photo);
								if (res.msg == '操作成功') {
									this.userInfo.isRead = res.data.params.isRead;
									this.userInfo.nickName = res.data.name;
									this.userInfo.photo = (res.data.avatar == "" || res.data.avatar == null) ?
										"../static/weiDL.png" : res.data.avatar;
									let porx = res.data.params.proxy
									if (porx.length > 0) {
										porx.forEach(item => {
											if (item.type == 2) {
												this.xiaoqu = true
											}
											if (item.type == 0) {
												this.tuijain = true
											}
											if (item.type == 1) {
												this.quxian = true
											}
										})
									}
								} else {
									this.putong = true
								}
								//console.log("====>"+this.userInfo.photo)
								if (res.data.money) {
									this.userInfo.balance = res.data.money.toFixed(2);
								} else {
									this.userInfo.balance = 0
								}
								this.userInfo.activity_photo = res.data.params.huoDongUrl.photo;
								this.userInfo.activety_url = res.data.params.huoDongUrl.url;
								// // //console.log(this.userInfo);
							});
						}
					},
					xitongxinxi() {
						if (this.isLogin == false) {
							this.loginUtil.goLogin(this);
						} else {
							uni.navigateTo({
								url: "../pagesB/my/xitongxiaoxi"
							})
						}
					},
					goYiJian() {
						if (this.isLogin == false) {
							this.loginUtil.goLogin(this);
						} else {
							uni.navigateTo({
								url: '../pagesB/my/yijianfankui'
							})
						}
					},
					goJuBao() {
						if (this.isLogin == false) {
							this.loginUtil.goLogin(this);
						} else {
							uni.navigateTo({
								url: '../pagesB/my/jubao'
							})
						}
					},
					goCoupon() {
						if (this.isLogin == false) {
							this.loginUtil.goLogin(this);
						} else {
							// uni.navigateTo({
							// 	url: '../pagesB/my/coupon'
							// })
							uni.navigateTo({
								url: '../pagesB/my/qianBao'
							})

						}
					},
					goSetting() {
						uni.navigateTo({
							url: '../pagesB/my/setting'
						})
					},
					goAbout() {
						if (this.isLogin == false) {
							this.loginUtil.goLogin(this);
						} else {
							uni.navigateTo({
								url: '../pagesB/my/about_me'
							})
						}
					},
					goService() {
						if (this.isLogin == false) {
							this.loginUtil.goLogin(this);
						} else {
							uni.navigateTo({
								url: "../pagesB/my/xieyi?url=" + this.$store.state.url_3
							})
						}
					},
					goInfo() {
						if (this.isLogin == false) {
							this.loginUtil.goLogin(this);
						} else {
							uni.navigateTo({
								url: '../pagesB/my/my_info'
							})
						}
					},
					goQianBao() {
						if (this.isLogin == false) {
							this.loginUtil.goLogin(this);
						} else {
							uni.navigateTo({
								url: '../pagesB/my/qianBao'
							})
						}
					},
					goGuanZhu() {
						if (this.isLogin == false) {
							this.loginUtil.goLogin(this);
						} else {
							uni.navigateTo({
								url: '../pagesB/my/my_guan_zhu'
							})
						}
					},
					yueDetail() {
						uni.navigateTo({
							url: '../pagesB/my/yue'
						})
					},
					redDetail() {
						uni.navigateTo({
							url: '../pagesB/my/hongbao'
						})
					},
			}

		}
</script>
<style scoped>
	.img_box image {
		border-radius: 10rpx;
		width: 90rpx;
		height: 35rpx;
		margin-right: 10rpx;
	}
	.ml-9 {
		margin-left: 18rpx;
	}

	.ml-13 {
		margin-left: 26rpx;
	}

	.ml-10-5 {
		margin-left: 21rpx;
	}

	.mt-6-5 {
		margin-top: 13rpx;
	}

	.ml-14-5 {
		margin-left: 29rpx;
	}

	.mt-17 {
		margin-top: 34rpx;
	}

	.ml-15-5 {
		margin-left: 31rpx;
	}

	.page {
		padding-bottom: 289rpx;
		background-color: #f8fbff;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
	}

	.section {
		padding-bottom: 96rpx;
		background-image: url('https://baijixing.oss-cn-chengdu.aliyuncs.com/2025/JUNE/3/1748943261990_2ad91055-e101-4a0a-b53c-fc6a68b47dbf.png');
		background-size: 100% 100%;
		background-repeat: no-repeat;
	}

	.image-wrapper {
		background-color: #00000000;
		height: 150rpx;
	}

	.group_2 {
		margin-top: 8rpx;
		padding: 0 28rpx;
	}

	.image-wrapper_2 {
		padding: 2rpx 0;
		border-radius: 60rpx;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		width: 124rpx;
		height: 124rpx;
	}

	.image_4 {
		width: 120rpx;
		height: 120rpx;
	}

	.text {
		color: #333333;
		font-size: 36rpx;
		font-family: PingFangSC;
		font-weight: 500;
		line-height: 25rpx;
	}

	.text-wrapper {
		padding: 8rpx 0 10rpx;
		border-radius: 8rpx;
	}

	.text_2 {
		margin-left: 10rpx;
		margin-right: 7rpx;
		color: #ffffff;
		font-size: 22rpx;
		font-family: PingFangSC;
		line-height: 20rpx;
	}

	.group_3 {
		margin-right: 8rpx;
	}

	.image_5 {
		width: 48rpx;
		height: 48rpx;
	}

	.image_6 {
		width: 48rpx;
		height: 47rpx;
	}

	.equal-division {
		margin: 28rpx 29rpx 0 30rpx;
	}

	.section_4 {
		flex: 1 1 331rpx;
	}

	.equal-division-item {
		padding: 27rpx 30rpx;
		background-color: #ffffff;
		border-radius: 16rpx;
		height: 118rpx;
	}

	.image_7 {
		width: 65rpx;
		height: 64rpx;
	}

	.group_4 {
		width: 185rpx;
	}

	.font {
		font-size: 30rpx;
		font-family: PingFangSC;
		line-height: 23rpx;
		color: #333333;
	}

	.text_3 {
		line-height: 24rpx;
	}

	.font_2 {
		font-size: 22rpx;
		font-family: PingFang;
		line-height: 21rpx;
		color: #999999;
	}

	.list {
		margin-right: 30rpx;
		margin-left: 30rpx;
		padding: 0 30rpx;
		background-color: #ffffff;
		border-radius: 16rpx;
	}

	.list-item_1 {
		padding: 33rpx 0;
		border-bottom: solid 1rpx #efefef;
	}

	.image_8 {
		width: 44rpx;
		height: 38rpx;
	}

	.font_3 {
		font-size: 24rpx;
		font-family: PingFangSC;
		line-height: 23rpx;
		font-weight: 500;
		color: #333333;
	}

	.image_9 {
		margin-right: 9rpx;
		width: 16rpx;
		height: 29rpx;
	}

	.ml-15 {
		margin-left: 30rpx;
	}

	.font_3 {
		font-size: 24rpx;
		font-family: PingFangSC;
		line-height: 23rpx;
		font-weight: 500;
		color: #333333;
	}

	.image_9 {
		margin-right: 9rpx;
		width: 16rpx;
		height: 29rpx;
	}

	.list-item {
		padding: 30rpx 0 31rpx;
		border-bottom: solid 1rpx #efefef;
	}

	.image_10 {
		width: 44rpx;
		height: 43rpx;
	}

	.ml-15-5 {
		margin-left: 31rpx;
	}

	.font_3 {
		font-size: 24rpx;
		font-family: PingFangSC;
		line-height: 23rpx;
		font-weight: 500;
		color: #333333;
	}

	.image_9 {
		margin-right: 9rpx;
		width: 16rpx;
		height: 29rpx;
	}

	.list-item_7 {
		padding: 30rpx 0;
		border-bottom: solid 1rpx #efefef;
	}

	.image_11 {
		width: 44rpx;
		height: 44rpx;
	}

	.ml-15-5 {
		margin-left: 31rpx;
	}

	.font_3 {
		font-size: 24rpx;
		font-family: PingFangSC;
		line-height: 23rpx;
		font-weight: 500;
		color: #333333;
	}

	.image_9 {
		margin-right: 9rpx;
		width: 16rpx;
		height: 29rpx;
	}

	.list-item_7 {
		padding: 30rpx 0;
		border-bottom: solid 1rpx #efefef;
	}

	.image_11 {
		width: 44rpx;
		height: 44rpx;
	}

	.ml-15-5 {
		margin-left: 31rpx;
	}

	.font_3 {
		font-size: 24rpx;
		font-family: PingFangSC;
		line-height: 23rpx;
		font-weight: 500;
		color: #333333;
	}

	.image_9 {
		margin-right: 9rpx;
		width: 16rpx;
		height: 29rpx;
	}

	.list-item {
		padding: 30rpx 0 31rpx;
		border-bottom: solid 1rpx #efefef;
	}

	.image_10 {
		width: 44rpx;
		height: 43rpx;
	}

	.ml-16-5 {
		margin-left: 33rpx;
	}

	.font_3 {
		font-size: 24rpx;
		font-family: PingFangSC;
		line-height: 23rpx;
		font-weight: 500;
		color: #333333;
	}

	.image_9 {
		margin-right: 9rpx;
		width: 16rpx;
		height: 29rpx;
	}

	.list-item_4 {
		padding: 30rpx 3rpx 0;
		border-bottom: solid 1rpx #efefef;
	}

	.image_12 {
		width: 39rpx;
		height: 44rpx;
	}

	.image_13 {
		margin-right: 6rpx;
	}

	.ml-15-5 {
		margin-left: 31rpx;
	}

	.font_3 {
		font-size: 24rpx;
		font-family: PingFangSC;
		line-height: 23rpx;
		font-weight: 500;
		color: #333333;
	}

	.image_9 {
		margin-right: 9rpx;
		width: 16rpx;
		height: 29rpx;
	}

	.list-item_3 {
		padding: 60rpx 0 30rpx;
		border-bottom: solid 1rpx #efefef;
	}

	.image_14 {
		width: 43rpx;
		height: 44rpx;
	}

	.ml-16-5 {
		margin-left: 33rpx;
	}

	.font_3 {
		font-size: 24rpx;
		font-family: PingFangSC;
		line-height: 23rpx;
		font-weight: 500;
		color: #333333;
	}

	.image_9 {
		margin-right: 9rpx;
		width: 16rpx;
		height: 29rpx;
	}

	.image_10 {
		width: 44rpx;
		height: 43rpx;
	}

	.list-item_2 {
		padding: 32rpx 0 29rpx;
	}
</style>